package com.app.micaihu.view.camera.utils;

import android.app.Activity;
import android.content.DialogInterface;


import androidx.appcompat.app.AlertDialog;

import com.app.micaihu.R;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.StringUtils;

public class DialogUtils {

    public static void showTwoBtnDialog(String message, DialogInterface.OnClickListener okClick) {
        showTwoBtnDialog(message, StringUtils.getString(android.R.string.ok), okClick);
    }

    public static void showTwoBtnDialog(String message, String ok, DialogInterface.OnClickListener okClick) {
        Activity topActivity = ActivityUtils.getTopActivity();
        new AlertDialog.Builder(topActivity)
                .setTitle(topActivity.getString(R.string.dialog_title))
                .setMessage(message)
                .setPositiveButton(ok, okClick)
                .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss())
                .setCancelable(false)
                .create()
                .show();
    }

    public static void showRationaleDialog(DialogInterface.OnClickListener okClick, DialogInterface.OnClickListener cancelClick) {
        Activity topActivity = ActivityUtils.getTopActivity();
        new AlertDialog.Builder(topActivity)
                .setTitle(android.R.string.dialog_alert_title)
                .setMessage(R.string.permission_rationale_message)
                .setPositiveButton(android.R.string.ok, okClick)
                .setNegativeButton(android.R.string.cancel, cancelClick)
                .setCancelable(false)
                .create()
                .show();
    }

    public static void showOpenAppSettingDialog(DialogInterface.OnClickListener okClick, DialogInterface.OnClickListener cancelClick) {
        Activity topActivity = ActivityUtils.getTopActivity();
        new AlertDialog.Builder(topActivity)
                .setTitle(android.R.string.dialog_alert_title)
                .setMessage(R.string.permission_denied_forever_message)
                .setPositiveButton(android.R.string.ok, okClick)
                .setNegativeButton(android.R.string.cancel, cancelClick)
                .setCancelable(false)
                .create()
                .show();
    }

}
